from time import sleep

from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait

# WebDriverWait()
from selenium.webdriver.support.wait import WebDriverWait
from utils.DriverUtils import DriverUtils

test_url = "http://local.shop.com/index.php/Home/index/index.html"

try:

    driver = DriverUtils.get_driver()
    driver.get(test_url)

    vivo = WebDriverWait(driver, 10, 0.5).until(EC.presence_of_element_located((By.XPATH, '/html/body/div[5]/div[2]/div[2]/a[1]/div[2]')))
    print(111111111111111111111)
    mtg = WebDriverWait(driver, 10, 0.5).until(lambda driver: driver.find_element(By.XPATH, '/html/body/div[9]/div[2]/div[2]/a[2]/div[1]/img'))
    print(22222222222222222222222)
    mtg.click()
    print(33333333333333333)
    # print(vivo.text)
    # vivo.click()
    sleep(5)
except Exception as e:
    print('Exception: ', e)

finally:
    DriverUtils.quit_driver()

    # input('Selenium running done.') #使Python主程序不结束
    pass
